<template>
  <div class="home">
    <el-container>
      <el-header>
        <div class="box">
          <h2>Logo</h2>
          <h2>电商后台管理系统</h2>
          <el-button type="info" @click="tuichu">退出登录</el-button>
        </div>
      </el-header>
      <el-container>
        <el-aside :width="iscollapse ? '68px' : '200px'">
          <div class="iconbox" @click="iscollapse = !iscollapse">
            <i class="el-icon-more-outline"></i>
          </div>
          <el-menu
            :default-active="$route.path"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            :router="true"
            :collapse="iscollapse"
          >
            <el-submenu
              :index="item.id + ''"
              v-for="item in menuslist"
              :key="item.id"
            >
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{ item.authName }}</span>
              </template>
              <el-menu-item
                :index="'/' + item1.path"
                v-for="item1 in item.children"
                :key="item1.id"
              >
                <span>{{ item1.authName }}</span>
              </el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { Message } from "element-ui";
import { menusapi } from "@/http/api";
export default {
  name: "HomeView",
  components: {},
  data() {
    return {
      menuslist: [],
      iscollapse: false,
    };
  },
  created() {
    menusapi().then((res) => {
      if (res.data.meta.status == 200) {
        Message({
          message: res.data.meta.msg,
          type: "success",
        });
        this.menuslist = res.data.data;
      }
    });
  },
  methods: {
    tuichu() {
      this.$router.push("/");
    },
  },
};
</script>
<style lang="scss" scoped>
.el-header {
  background-color: #363c42;
  color: #fff;
  text-align: center;
  .box {
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
}

.el-aside {
  background-color: #313743;
  color: #fff;
  text-align: center;
  height: 100vh;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  height: 100vh;
}
</style>
